using System;
using System.Windows.Forms;

public class DGVCalendarCell : DataGridViewTextBoxCell
{
    public DGVCalendarCell()
        : base()
    {
        // Use the short date format.
        this.Style.Format = "d";
    }

    public override void InitializeEditingControl(int rowIndex, object initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle)
    {
        // Set the value of the editing control to the current cell value.
        base.InitializeEditingControl(rowIndex, initialFormattedValue, dataGridViewCellStyle);

        DGVCalendarEditingControl _ctl = (DGVCalendarEditingControl)this.DataGridView.EditingControl;

        if (initialFormattedValue == null || (string)initialFormattedValue == "")
            _ctl.Value = DateTime.Now;
        else
            _ctl.Value = DateTime.Parse((string)initialFormattedValue);
    }

    public override Type EditType
    {
        get
        {
            // Return the type of the editing contol that CalendarCell uses.
            return typeof(DGVCalendarEditingControl);
        }
    }

    public override Type ValueType
    {
        get
        {
            // Return the type of the value that CalendarCell contains.
            return typeof(DateTime);
        }
    }

    /*public override object DefaultNewRowValue
    {
        get
        {
            // Use the current date and time as the default value.
            return DateTime.Now;
        }
    }*/
}
